<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增专业')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-specialized-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专业名称：</label>
                <div class="col-sm-8">
                    <input name="proName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">组织机构：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="deptId" id="treeId" type="hidden">
                        <input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control" required>
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">父：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group">-->
<!--                        <input id="treeId" name="parentId" type="hidden" th:value="${specialized?.id}"/>-->
<!--                        <input class="form-control" type="text" onclick="selectSpecializedTree()" id="treeName" readonly="true" th:value="${specialized?.proName}">-->
<!--                        <span class="input-group-addon"><i class="fa fa-search"></i></span>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "edu/specialized"
        $("#form-specialized-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-specialized-add').serialize());
            }
        }

        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }

        // /*专业-新增-选择父部门树*/
        // function selectSpecializedTree() {
        //     var options = {
        //         title: '专业选择',
        //         width: "380",
        //         url: prefix + "/selectSpecializedTree/" + $("#treeId").val(),
        //         callBack: doSubmit
        //     };
        //     $.modal.openOptions(options);
        // }
        //
        // function doSubmit(index, layero){
        //     var body = layer.getChildFrame('body', index);
        //        $("#treeId").val(body.find('#treeId').val());
        //        $("#treeName").val(body.find('#treeName').val());
        //        layer.close(index);
        // }
    </script>
</body>
</html>
